package com.tadpole.music.adapter.me;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.tadpole.music.R;
import com.tadpole.music.adapter.base.BaseAdapter;
import com.tadpole.music.bean.me.ZhenTiSearchBean;
import com.tadpole.music.holder.base.BaseViewHolder;
import com.tadpole.music.holder.base.NoDataEmpty;
import com.tadpole.music.holder.me.WorkV2ViewHolder;
import com.tadpole.music.holder.me.ZhenTiWorkViewHolder;

/**
 * Created By 孙岩
 * on 2020/12/26
 */
public class ZhenTiWorkAdapter extends BaseAdapter {
    private Activity activity;
    private ZhenTiWorkViewHolder zhenTiWorkViewHolder;
    private OnItemClickListener onItemClickListener;
    private ZhenTiSearchBean.DataBean bean;

    public ZhenTiWorkAdapter(Activity activity,ZhenTiSearchBean.DataBean bean){
        this.activity = activity;
        this.bean = bean;
    }


    @Override
    public BaseViewHolder createRelHolder(ViewGroup parent, int viewType) {
        if (bean == null || bean.getMonth_exam_static().size()==0||bean.getMonth_exam_static().size() == 0) {
            String empty = "NO_DATA";
            LayoutInflater layoutInflater = LayoutInflater.from(activity);
            View inflate = layoutInflater.inflate(R.layout.item_no_data, parent, false);
            NoDataEmpty noDataEmpty = new NoDataEmpty(inflate, empty);
            return noDataEmpty;
        } else {
            zhenTiWorkViewHolder = new ZhenTiWorkViewHolder(LayoutInflater.from(activity).inflate(R.layout.item_v2_work_zhenti, parent, false), bean, onItemClickListener);
            return zhenTiWorkViewHolder;
        }
    }

    @Override
    public int getRelItemCount() {
        return bean==null||bean.getMonth_exam_static()==null||bean.getMonth_exam_static().size()==0?1:bean.getMonth_exam_static().size();
    }

    @Override
    public void setOnItemClickListener(OnItemClickListener listener) {
        this.onItemClickListener = listener;
    }

    @Override
    public void setOnChildClickListener(OnChildClickListener listener) {

    }

    @Override
    public void setOnLongClickListener(OnLongClickListener listener) {

    }

    @Override
    public void onBindViewHolder(@NonNull BaseViewHolder holder, int position) {
        holder.init(position - mHeadViews.size());
    }
}
